"""
for QPython OH
open local http share in path dp
you can also do so in pyftpdlib
and pyftp
"""
import os
from random import randint
cmd="/data/user/0/com.hipipal.qpyplus/files/bin/qpython3-android5.sh -m http.server"
#Your path to share
dp="/storage/emulated/0/"
#dp="/data/user/0/com.hipipal.qpyplus/files"
os.chdir(dp)
with os.popen("ip addr show |"
    	" grep 'inet 192' |"
    	" sed 's/[^\/0-9\.]//g' |"
    	" sed 's/\/.*//g'") as fp:
 ipstr=fp.read()
ipstr=ipstr[0:len(ipstr)-1]

while 1:
 i=randint(1024,65535)
 arg=" %d"%i
 print("\n\nenter %s\n\n"%(
  	ipstr+":"+arg[1:]))
 print("hit Control-C to quit")
 ret=os.system(cmd+arg)
 print("exitcode=", ret)
 #listen to 0.0.0.0 means 
 # listen to any ip thats points
 # here
 if ret in (33280,0): break
